local hx__fenyin = fk.CreateSkill {
  name = "hx__fenyin",
}


hx__fenyin:addEffect(fk.CardUsing, {
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__fenyin.name) and (data.extra_data or {}).can_hx__fenyin
  end,
  on_use = function(self, event, target, player, data)
    player:drawCards(1, hx__fenyin.name)
  end,
})
hx__fenyin:addEffect(fk.CardUsing, {
  can_refresh = function(self, event, target, player, data)
    return target == player and player:hasSkill(hx__fenyin.name, true) and
      data.card.suit ~= Card.NoSuit and player.room.current == player
  end,
  on_refresh = function(self, event, target, player, data)
    local room = player.room
    local mark = player:getMark("@hx__fenyin-turn")
    if mark ~= 0 and mark ~= data.card:getSuitString(true) then
      data.extra_data = data.extra_data or {}
      data.extra_data.can_hx__fenyin = true
    end
    room:setPlayerMark(player, "@hx__fenyin-turn", data.card:getSuitString(true))
  end,
})

return hx__fenyin
